package com.cans.lightning.business.system.service.impl;

import com.cans.lightning.base.mapper.IBaseMapper;
import com.cans.lightning.base.service.impl.BaseServiceImpl;
import com.cans.lightning.business.system.dao.SystemConfigDao;
import com.cans.lightning.business.system.dto.SystemConfigDto;
import com.cans.lightning.business.system.entity.SystemConfig;
import com.cans.lightning.business.system.mapper.SystemConfigMapperI;
import com.cans.lightning.business.system.service.api.ISystemConfigService;
import lombok.extern.slf4j.Slf4j;
import org.beetl.sql.mapper.BaseMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 系统配置服务
 *
 * @author shencan
 * @date 2020/6/14 20:53
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class SystemConfigServiceImpl extends BaseServiceImpl<SystemConfig, SystemConfigDto, String> implements ISystemConfigService {

    @Resource
    private SystemConfigDao systemConfigDao;
    @Resource
    private SystemConfigMapperI systemConfigMapper;


    @Override
    public BaseMapper<SystemConfig> getDaoImpl() {
        return systemConfigDao;
    }

    @Override
    public IBaseMapper<SystemConfig, SystemConfigDto, String> getMapperImpl() {
        return systemConfigMapper;
    }

    @Override
    public SystemConfig getByKeyCode(String configKey) {
        return systemConfigDao.createLambdaQuery().andEq(SystemConfig::getKeyCode, configKey).single();
    }
}
